package level.editor.view.action;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import level.editor.control.main.Main;
import level.editor.control.main.MainTabbed;

public class SelectHandlerAction extends AbstractAction
{
	public SelectHandlerAction(String name, MainTabbed tabbed)
	{
		super("Select the " + name);
		type = name;
		this.tabbed = tabbed;
	}

	@Override
	public void actionPerformed(ActionEvent arg0)
	{
		if (tabbed.getHandler(type) != null)
		{
			Main main = tabbed.getSelectedMain();
			main.removeHandler(main.getHandler());
			main.addHandler(tabbed.getHandler(type));
			main.repaint();
		}
		else
		{
			System.out.println("Something went wrong in SelectHandlerAction");
		}
	}

	private String type;
	private MainTabbed tabbed;
	public static final String TILE_HANDLER = "Tile Tool";
	public static final String COLLISION_HANDLER = "Collision Tool";
	public static final String SELECT_HANDLER = "Select Tool";
	public static final String OBJECT_HANDLER = "Object Tool";
}
